/*  
	------------------------------------------------------------------------
	 NQ Core Library
	
	 Homepage: http://www.awzhome.de/
	------------------------------------------------------------------------
	
	This Source Code Form is subject to the terms of the Mozilla Public
	License, v. 2.0. If a copy of the MPL was not distributed with this
	file, You can obtain one at http://mozilla.org/MPL/2.0/.
   
	The Original Code is code of NQ Core Library.

	The Initial Developer of the Original Code is Andreas Weizel.
	Portions created by the Initial Developer are
	Copyright (C) 2012 Andreas Weizel. All Rights Reserved.
	
	Contributor(s): (none)
	
	------------------------------------------------------------------------
*/

using System;
using System.Collections.Generic;
using System.Text;

namespace AWZhome.NQ.Core
{
	/// <summary>
	/// A central access point to the service manager implementation.
	/// </summary>
	public static class NQServiceManager
	{
		private static INQServiceManager servManager = null;

		/// <summary>
		/// Sets a new global implementation of the service manager.
		/// </summary>
		/// <param name="newManager">Instance of an <see cref="AWZhome.NQ.Core.INQServiceManager">INQServiceManager</see> implementation.</param>
		/// <remarks>
		/// This method can only be called when no manager instance has been specified yet,
		/// the specified Service Manager is not initialized or is already destroyed.
		/// Any further attempts lead to an exception.
		/// </remarks>
		public static void SetImplementation(INQServiceManager newManager)
		{
			if ((servManager == null) || !servManager.IsActive)
			{
				servManager = newManager;
			}
			else
			{
				throw new Exception("Service manager implementation is already defined and active.");
			}
		}

		/// <summary>
		/// Returns the global instance of the active service manager or <c>null</c>,
		/// if no service manager has been set yet.
		/// </summary>
		public static INQServiceManager Instance
		{
			get
			{
				return servManager;
			}
		}
	}
}
